#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
int n;
int a[N];
ll dp[N];
int main() {
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=3;i<=n;i++)
    {
        dp[i]=max(dp[i-1],dp[i-3]+a[i-1]);
    }
    cout << dp[n] << endl;
    return 0;
}